<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::any('/wechat', 'WeChatController@serve');

Route::any('/{path}/t', 'TestController@test')->where('path', '.*');
Route::any('/t', 'TestController@test');

Route::get('/', 'HomeController@home');

Route::group([
    'prefix' => 'admin',
    'as'     => 'admin.',
], function () {
    Route::group(['namespace' => 'Auth'], function () {
        Route::get('/login', 'LoginController@showLoginForm')->name('login');
        Route::post('/login', 'LoginController@login');

        Route::get('/logout', 'LoginController@logout')->name('logout');
    });

    Route::group([
        'namespace'  => 'Admin',
        'middleware' => 'auth',
    ], function () {
        Route::get('/', 'IndexController@index')->name('index');

        Route::post('configs/upload', 'ConfigController@upload')->name('configs.upload');
        Route::resource('configs', 'ConfigController');

        Route::resource('menus', 'MenuController');
        Route::resource('users', 'UserController');
        Route::resource('roles', 'RoleController');
        Route::resource('permissions', 'PermissionController');

        Route::resource('lottos', 'LottoController');
        Route::resource('lotto-players', 'LottoPlayerController');
    });
});

Route::post('/lottos/{lotto}/award', 'LottoController@giveAward');
Route::post('/lottos/{lotto}/reset-current', 'LottoController@resetCurrent');
Route::post('/lottos/{lotto}/replay', 'LottoController@replay');
Route::get('/lottos/{lotto}/join', 'LottoController@join')->name('lottos.join')->middleware('wechat.oauth.multi');
Route::get('/lottos/{lotto}', 'LottoController@show')->name('lottos.show');
